<template>
  <div class="grid" @click="() => emit('detailBtn')">
    <div class="grid_header">
      <div class="name" >{{ props.routeData.routeName }}</div>
      <!-- <div class="detail">
        <el-link type="primary" @click="() => emit('detailBtn')">详细页面 ></el-link>
      </div> -->
    </div>

    <div class="grid_main">

      <div class="detail_data">
        <div class="detail_data_item" v-for="item in routeDetail" :key="item.value">
          <span>{{ item.key }}</span>
          <span class="detail_data_item_text">{{ props.routeData[item.value] }}</span>
        </div>
      </div>

      <div class="detail_percent">
        <div class="detail_percent_item" v-for="item in routePercent" :key="item.value">
          <el-progress type="circle" :percentage="props.routeData[item.value]" :width="80" :color="item.color">
            <template #default="{ percentage }">
              <span class="percentage-value" :style="{ color: item.color }">{{ Math.floor(percentage) }}%</span>
            </template>
          </el-progress>
          <div class="detail_percent_item_name">{{ item.key }}</div>
        </div>
      </div>

    </div>
  </div>
</template>

<script setup>
const props = defineProps({
  routeData: Object
})
const emit = defineEmits(['detailBtn'])
const routeDetail = [
  {
    key: '今日排车数',
    value: 'planVehicles'
  },
  {
    key: "全天计划趟次",
    value: 'planItineraries'
  },
  {
    key: '当前计划',
    value: 'currentItineraries'
  },
  {
    key: '已执行趟次',
    value: 'executedItineraries'
  }
]
const routePercent = [
  {
    key: '趟次完成率',
    value: 'rateExecutedItinerary',
    color: '#50a9f8'
  },
  {
    key: '发车准点率',
    value: 'onTimeDepartureRate',
    color: '#4cd279'
  },
  {
    key: '到站正点率',
    value: 'onTimeStationRate',
    color: '#4cd279'
  }
]
</script>

<style lang="scss" scoped>
.grid {
  display: flex;
  flex-direction: column;
  width: 390px;
  height: 262px;
  background: #FFFFFF;
  box-shadow: 0px 0px 10px 0px rgba(0, 0, 0, 0.08);
  border-radius: 10px;
  margin-right: 25px;
  margin-bottom: 20px;
  background-color: #11224B;

  &:hover {
    cursor: pointer;
    background: #1C2F61;
    box-shadow: 0px 0px 18px 0px rgba(102, 143, 245, 0.24);
  }

  .grid_header {
    display: flex;
    justify-content: space-between;
    padding-right: 16px;
    align-items: center;
    height: 40px;
    border-bottom: 1px solid #668FF5;

    .name {
      box-sizing: border-box;
      width: 75px;
      padding: 0px 5px;
      height: 100%;
      line-height: 40px;
      text-align: center;
      // background-color: #668ff5;
      color: #fff;
      overflow: hidden;
      white-space: nowrap;
      text-overflow: ellipsis;
      font-size: 16px;
      font-weight: 600;
      cursor: default;
    }
  }

  .grid_main {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px 30px;

    .detail_data {
      flex: 1;
      display: flex;
      flex-wrap: wrap;

      .detail_data_item {
        font-size: 14px;
        color: #9BAFD6;
        width: 50%;

        .detail_data_item_text {
          color: #fff;
          margin-left: 8px;
        }
      }
    }

    .detail_percent {
      flex: 1;
      width: 100%;
      display: flex;
      justify-content: space-between;

      .detail_percent_item {
        display: flex;
        flex-direction: column;
        align-items: center;

        .percentage-value {
          font-size: 20px;
        }

        .detail_percent_item_name {
          color: #9BAFD6;
          font-size: 14px;
          margin-top: 8px;
        }
      }
    }
  }
}</style>